package xin.yangshuai.juc01.hello;

/**
 * Question3
 *
 * @author shuai
 * @date 2022/2/11
 */
public class Question3 {

    public synchronized void a(Question33 question33) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        question33.b();
    }

    public synchronized void b() {
        System.out.println("Question3");
    }
}

class Question33 {


    public synchronized void a(Question3 question3) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        question3.b();
    }

    public synchronized void b() {
        System.out.println("Question33");
    }
}

class Result3 {
    public static void main(String[] args) {

        Question3 question3 = new Question3();
        Question33 question33 = new Question33();
        new Thread(() -> {
            question3.a(question33);
        }).start();
        new Thread(() -> {
            question33.a(question3);
        }).start();
    }
}
